<template>
	<div>
		<div class="pub-title">后台管理</div>
		<ul class="pub-tab">
			<li class="option-list">
				<a href="article.html" class="option on">文章</a>
				<!-- <a href="article_classify.html" class="option">分类</a> -->
			</li>
			<li class="tab-block-list">
				<div class="head-tip">
					<select v-model="classify">
						<option value="">全部</option>
						<option value="1">易学文章</option>
						<option value="2">关于我们</option>
					</select>
					<input type="text" class="pub-input" v-model="title" placeholder="文章标题" />
					<button class="pub-btn" @click="search">搜索</button>
					<a class="pub-btn" href="article_detail.html?type=add">+ 新增文章</a>
				</div>
				<div style="padding:30px 0;text-align: center;" v-show="list.length<1">暂无数据</div>
				<table class="pub-table" v-show="list.length>0">
					<tr>
						<th width="80">排序</th>
						<th>标题</th>
						<th>文章分类</th>
						<th>是否显示</th>
						<th>更新时间</th>
						<th width="300">操作</th>
					</tr> 

					<tr class="checkbox" v-for="(v,k) in list">
						<td>{{v.sort.toString().replace(/^0+/,"")}}</td>
						<td>{{v.title}}</td>
						<td>{{options[v.classify]}}</td>
						<td>{{v.isshow==1?"显示":"不显示"}}</td>
						<td>{{$parent.formatDate(v.update_time)}}</td>
						<td> 
							<a :href="'article_detail.html?id='+v._id" class="pub-btn">编辑</a>
							<button class="pub-btn">删除</button>
						</td>
					</tr>

					<tr class="last">
						<td><input type="checkbox" /> 全选</td>
						<td colspan="5">
							<paging :data="paging" :url="url" style="float:right; margin-right: 10px;"></paging>
						</td>
					</tr> 
				</table>
			</li>
		</ul>
	</div>
</template>
<script>
	module.exports = {
		data(){
			return {
				options: {"1":"易学文章","2":"关于我们"},
				list: [],
				title: "",
				classify:'',
				paging:{},
				url:''
			}
		},
		components:{
			'paging':require('./component/paging.vue').default
		},
		methods: {
			del(id, item) {

			},
			search(){
				var data=""
				data+='title='+this.title;
				data+='&classify='+this.classify;
				location.href='article.html?'+data;
			},
			getList() {
				let data={
					page:query.page?query.page:1,
					title:query.title?query.title:"",
					classify:query.classify?query.classify:""		
				};
				this.classify=data.classify;
				this.title=data.title;
				ajax({
					url:"article/list",
					data:data,
					success:function(res){
						if(res.state==1){
							_this.list=res.data.list;
							_this.paging=res.data.paging;
						}else{
							UI.alert(res.msg);
						}
					}
				})
			}
		}, 
		created() {
			_this=this;
			this.getList();
			this.url=location.href;
		}
	}
</script>
